using System.Collections.Generic;
using Microsoft.Xrm.Sdk;

namespace OrbitOne.CRMLyncInfoDashboard.CRM.Plugins
{
    public class SearchFieldProviderFactory : ISearchFieldProviderFactory
    {
        private readonly IDictionary<string, SearchFieldProvider> m_searchFieldProviders
            = new Dictionary<string, SearchFieldProvider>
                  {
                      {"account", new AccountSearchFieldProvider()},
                      {"contact", new ContactSearchFieldProvider()},
                      {"lead", new LeadSearchFieldProvider()}
                  };
        
        public SearchFieldProvider Get(string entityLogicalName, IOrganizationService sdk)
        {
            if (!m_searchFieldProviders.ContainsKey(entityLogicalName)) return null;

            var searchFieldProvider = m_searchFieldProviders[entityLogicalName];
            searchFieldProvider.Sdk = sdk;
            return searchFieldProvider;
        }
    }
}